home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: Robert DiFalco <difalco@primenet.com>
- Newsgroups: comp.std.c++
- Subject: Re: Enhanced container functionality
- Date: 20 Jan 1996 16:22:23 GMT
- Organization: Primenet Services for the Internet
- Sender: root@primenet.com
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <4dphil$k6n@nnrp1.news.primenet.com>
- NNTP-Posting-Host: taumet.eng.sun.com
- Content-Type: text
- X-Posted-By: ip087.lax.primenet.com
- Content-Length: 1939
- Originator: clamage@taumet
-
- "Eugene Radchenko" <eugene@qsar.chem.msu.su> writes:
- > Hi!
- > Having used the STL for some time, I have come to greatly missing some nice
- > things (and eventually derived Vector<T> from vector<T>, adding them along
- > with persistence support).
- > First, it is the ability to (easily) flush the entire container
- > void erase() { erase(begin(), end()); }
- > Second, it is the 'post-factum' equivalents to some constructors
- > void assign(size_type n, T t = T());
- > void assign(const_iterator first, const_iterator last);
- > etc. - putting the container into the same state as the one it would have
- > after the respective constructor (with the possible exception of more
- > reserved space available).
- > I think these features deserve inclusion.
- >
-
- I'd have to disagree. I've often found operations like Erase,
- Clear, Assign and such as somewhat strange. Essentially, when
- you say "assign", you are saying give me a new container. If
- this is the case, why not just create a new container? Same
- with Erase. Why would you "erase" the entire contents of a
- container if not to create a new one? Assigning or erasing
- specific items is different since then you are just changing
- the container rather than recreating it. The only reasons I
- can see for wanting Erase and Assign would be efficiency where
- one would rather erase all the items of the current container
- and assign new ones rather than to simply create a new
- container. This seems semantically impure to me and I'd just
- instantiate a new one then resuse a current container that
- is no longer needed around. I would imagine the relative
- efficiency metrics between the two are about the same. You can
- even take this sort of thinking to things like ranges. Should
- one really be able to redefine the Upper or Lower bound of
- a range? Probably not, ranges are small and you are probably
- just better of creating a new one. For example, check out
- the differece between "a" and "b" below:
-
-
-
- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
- Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
- is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
-
-